<template>
  <div class="tabbar">
    <router-link
      v-for="nav in navs"
      :key="nav.path"
      :to="nav.path"
      tag="div"
    >
      <i class="iconfont" v-html="nav.meta.icon"></i>
      <span>{{ nav.meta.title }}</span>
    </router-link>
    <!-- <router-link to="/home" tag="div">
      <i class="iconfont">&#xe62c;</i>
      <span>首页</span>
    </router-link>
    <router-link to="/category" tag="div">
      <i class="iconfont">&#xe60e;</i>
      <span>分类</span>
    </router-link>
    <router-link to="/cart" tag="div">
      <i class="iconfont">&#xe610;</i>
      <span>购物车</span>
    </router-link>
    <router-link to="/mine" tag="div">
      <i class="iconfont">&#xe625;</i>
      <span>我的</span>
    </router-link> -->
  </div>
</template>

<script>
// 引入路由
import routes from '@/router/routes'

export default {
  name: 'Tabbar',
  computed: {
    /**
     * 计算要添加到组件的路由内容
     */
    navs () {
      return routes.filter(route => route.meta.isNav)
    }
  }
}
</script>

<style lang="scss" scoped>
.tabbar {
  display: flex;
  height: 40px;
  div {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .router-link-exact-active.router-link-active {
    background: #eee;
  }
}
</style>
